home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_bas
/
t2win_32.zip
/
_BITSTR.FRM
< prev
next >
Wrap
Text File
|
1996-05-14
|
22KB
|
813 lines
VERSION 4.00
Begin VB.Form frmBitString
BorderStyle = 4 'Fixed ToolWindow
Caption = "Bit string"
ClientHeight = 4545
ClientLeft = 1890
ClientTop = 3270
ClientWidth = 7485
Height = 4950
Left = 1830
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 4545
ScaleWidth = 7485
ShowInTaskbar = 0 'False
Top = 2925
Width = 7605
Begin Threed.SSPanel SSPanel2
Align = 2 'Align Bottom
Height = 465
Left = 0
TabIndex = 1
Top = 4080
Width = 7485
_Version = 65536
_ExtentX = 13203
_ExtentY = 820
_StockProps = 15
BackColor = 12632256
Begin VB.TextBox Text1
Height = 285
Left = 1440
TabIndex = 3
Tag = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Top = 90
Width = 5055
End
Begin Threed.SSCommand SSCommand2
Height = 285
Left = 6570
TabIndex = 4
Top = 90
Width = 825
_Version = 65536
_ExtentX = 1455
_ExtentY = 503
_StockProps = 78
Caption = "&Reset"
BevelWidth = 1
Outline = 0 'False
End
Begin VB.Label Label1
Caption = "&Enter a test string"
Height = 255
Left = 90
TabIndex = 2
Top = 120
Width = 1275
End
End
Begin Threed.SSPanel SSPanel1
Align = 1 'Align Top
Height = 480
Left = 0
TabIndex = 5
Top = 0
Width = 7485
_Version = 65536
_ExtentX = 13203
_ExtentY = 847
_StockProps = 15
ForeColor = -2147483640
BackColor = 12632256
Begin VB.ComboBox cmb_Function
Height = 315
Left = 1365
TabIndex = 6
Top = 90
Width = 4785
End
Begin Threed.SSCommand cmdNP
Height = 300
Index = 1
Left = 7140
TabIndex = 10
Top = 90
Width = 255
_Version = 65536
_ExtentX = 450
_ExtentY = 529
_StockProps = 78
Caption = ">"
BevelWidth = 1
Font3D = 3
RoundedCorners = 0 'False
Outline = 0 'False
End
Begin Threed.SSCommand cmdNP
Height = 300
Index = 0
Left = 6300
TabIndex = 9
Top = 90
Width = 255
_Version = 65536
_ExtentX = 450
_ExtentY = 529
_StockProps = 78
Caption = "<"
BevelWidth = 1
Font3D = 3
RoundedCorners = 0 'False
Outline = 0 'False
End
Begin VB.Label Label2
Caption = "&Select a function"
Height = 255
Left = 90
TabIndex = 8
Top = 120
Width = 1275
End
Begin Threed.SSCommand SSCommand1
Default = -1 'True
Height = 300
Left = 6615
TabIndex = 7
Top = 90
Width = 465
_Version = 65536
_ExtentX = 820
_ExtentY = 529
_StockProps = 78
Caption = "&Go"
BevelWidth = 1
RoundedCorners = 0 'False
Outline = 0 'False
End
End
Begin VB.Label lbl_Result
Appearance = 0 'Flat
BackColor = &H80000005&
BackStyle = 0 'Transparent
ForeColor = &H80000008&
Height = 3345
Left = 90
TabIndex = 0
Top = 630
Width = 7305
End
End
Attribute VB_Name = "frmBitString"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Option Base 1
Private Const Iteration = 250
Dim IsLoaded As Integer
Dim TimerStartOk As Integer
Dim TimerCloseOk As Integer
Dim TimerHandle As Integer
Dim TimerValue As Long
Private Sub cmb_Function_Click()
If (IsLoaded = False) Then Exit Sub
Call cDisableFI(mdiT2W.Picture1)
SSPanel2.Visible = True
lbl_Result = ""
DoEvents
Select Case cmb_Function.ListIndex
Case 0
SSPanel2.Visible = False
Call TestCreateBits
Case 1
Call TestFindBitReset
Case 2
Call TestFindBitSet
Case 3
Call TestGetBit
Case 4
SSPanel2.Visible = False
Call TestGiveBitPalindrome
Case 5
Call TestIsBitPalindrome
Case 6
Call TestReverseAllBits
Case 7
Call TestReverseAllBitsByChar
Case 8
Call TestSetAllBits
Case 9
Call TestSetBit
Case 10
Call TestToggleAllBits
Case 11
Call TestToggleBit
End Select
DoEvents
Call cEnableFI(mdiT2W.Picture1)
End Sub
Private Sub cmdNP_Click(Index As Integer)
Call sub_NextPrev(cmb_Function, Index)
End Sub
Private Sub Form_Activate()
mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
End Sub
Private Sub Form_Load()
IsLoaded = False
Show
Text1.Text = Text1.Tag + LCase$(Text1.Tag)
Call sub_Load_Combo(cmb_Function, T2WDirInst + "_bitstr.t2w")
IsLoaded = True
End Sub
Private Sub SSCommand1_Click()
Call cmb_Function_Click
End Sub
Private Sub TestCreateBits()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strResult = cCreateBits(1024)
strDisplay = strDisplay + "Create a bit string for 1024 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
strResult = cCreateBits(512)
strDisplay = strDisplay + "Create a bit string for 512 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
strResult = cCreateBits(33)
strDisplay = strDisplay + "Create a bit string for 33 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
strResult = cCreateBits(1)
strDisplay = strDisplay + "Create a bit string for 1 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
strResult = cCreateBits(-1)
strDisplay = strDisplay + "Create a bit string for -1 bits is '" & Len(strResult) & "' bytes" & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
strResult = cCreateBits(1024)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestFindBitReset()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
strDisplay = strDisplay + "The following bits are Reset (False) " & vbCrLf & vbCrLf
intResult = True
Do
intResult = cFindBitReset(strData, intResult)
If (intResult <> True) Then strDisplay = strDisplay & intResult & ", "
Loop Until (intResult = True)
strDisplay = Left$(strDisplay, Len(strDisplay) - 1)
strDisplay = strDisplay & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cFindBitReset(strData, i)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub SSCommand2_Click()
Text1.Text = Text1.Tag + LCase$(Text1.Tag)
Call SSCommand1_Click
End Sub
Private Sub TestFindBitSet()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
strDisplay = strDisplay + "The following bits are Set (True) " & vbCrLf & vbCrLf
intResult = True
Do
intResult = cFindBitSet(strData, intResult)
If (intResult <> True) Then strDisplay = strDisplay & intResult & ", "
Loop Until (intResult = True)
strDisplay = Left$(strDisplay, Len(strDisplay) - 1)
strDisplay = strDisplay & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cFindBitSet(strData, i)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestGetBit()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
strDisplay = strDisplay + "Bit '1' is '" & IIf(cGetBit(strData, 1), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '3' is '" & IIf(cGetBit(strData, 3), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '5' is '" & IIf(cGetBit(strData, 5), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '7' is '" & IIf(cGetBit(strData, 7), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '100' is '" & IIf(cGetBit(strData, 100), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '102' is '" & IIf(cGetBit(strData, 102), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '104' is '" & IIf(cGetBit(strData, 104), "set", "reset") & "'" & vbCrLf
strDisplay = strDisplay + "Bit '106' is '" & IIf(cGetBit(strData, 106), "set", "reset") & "'" & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cGetBit(strData, i)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestGiveBitPalindrome()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strResult = cGiveBitPalindrome()
strDisplay = strDisplay + "The followings chars are Bit Palindrome : " & vbCrLf & vbCrLf
strDisplay = strDisplay + "chr(0) and " & cBlockCharFromRight(cGiveBitPalindrome(), 1)
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
strResult = cGiveBitPalindrome()
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestIsBitPalindrome()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
intResult = cIsBitPalindrome(strData)
strDisplay = strDisplay + "Test string is " & IIf(intResult, "", "not ") & "Bit Palindrome " & vbCrLf & vbCrLf
strDisplay = strDisplay + "The followings chars are Bit Palindrome : " & vbCrLf
For i = 1 To 255
If cIsBitPalindrome(Chr$(i)) Then strDisplay = strDisplay + Chr$(i) & " (" & i & ") "
Next i
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
intResult = cIsBitPalindrome(strData)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestReverseAllBits()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
Call cReverseAllBits(strData)
strDisplay = strDisplay + "Reverse all bits is " & vbCrLf & strData & vbCrLf & vbCrLf
Call cReverseAllBits(strData)
strDisplay = strDisplay + "Reverse all bits of the reversed is " & vbCrLf & strData & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
Call cReverseAllBits(strData)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestReverseAllBitsByChar()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
Call cReverseAllBitsByChar(strData)
strDisplay = strDisplay + "Reverse all bits by char is " & vbCrLf & strData & vbCrLf & vbCrLf
Call cReverseAllBitsByChar(strData)
strDisplay = strDisplay + "Reverse all bits by char of the reversed is " & vbCrLf & strData & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
Call cReverseAllBitsByChar(strData)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestSetAllBits()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
Call cSetAllBits(strData, True)
strDisplay = strDisplay + "Set all bits is " & vbCrLf
strDisplay = strDisplay + strData & vbCrLf & vbCrLf
Call cSetAllBits(strData, False)
strDisplay = strDisplay + "Reset all bits is " & vbCrLf
strDisplay = strDisplay + strData & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
Call cSetAllBits(strData, True)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestSetBit()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
Call cSetBit(strData, 0, True)
strDisplay = strDisplay + "Set bit '0' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 5, True)
strDisplay = strDisplay + "Set bit '5' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 7, True)
strDisplay = strDisplay + "Set bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
Call cSetBit(strData, 0, False)
strDisplay = strDisplay + "Reset bit '0' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 5, False)
strDisplay = strDisplay + "Reset bit '5' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 7, False)
strDisplay = strDisplay + "Reset bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
Call cSetBit(strData, 22, True)
strDisplay = strDisplay + "Set bit '22' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 30, True)
strDisplay = strDisplay + "Set bit '30' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 38, True)
strDisplay = strDisplay + "Set bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
Call cSetBit(strData, 22, False)
strDisplay = strDisplay + "Reset bit '22' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 30, False)
strDisplay = strDisplay + "Reset bit '30' is '" & strData & "'" & vbCrLf
Call cSetBit(strData, 38, False)
strDisplay = strDisplay + "Reset bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
Call cSetBit(strData, 0, True)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestToggleAllBits()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
Call cToggleAllBits(strData)
strDisplay = strDisplay + "Toggle all bits is " & vbCrLf
strDisplay = strDisplay + strData & vbCrLf & vbCrLf
Call cToggleAllBits(strData)
strDisplay = strDisplay + "Toggle all bits of the toggled is " & vbCrLf
strDisplay = strDisplay + strData & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
Call cToggleAllBits(strData)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub
Private Sub TestToggleBit()
Dim intResult As Integer
Dim strResult As String
Dim strDisplay As String
Dim strData As String
Dim i As Integer
intResult = 0
strResult = ""
strDisplay = ""
strData = Text1.Text
Call cToggleBit(strData, 0)
strDisplay = strDisplay + "Toggle bit '0' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 5)
strDisplay = strDisplay + "Toggle bit '5' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 7)
strDisplay = strDisplay + "Toggle bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
Call cToggleBit(strData, 0)
strDisplay = strDisplay + "Toggle bit '0' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 5)
strDisplay = strDisplay + "Toggle bit '5' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 7)
strDisplay = strDisplay + "Toggle bit '7' is '" & strData & "'" & vbCrLf & vbCrLf
Call cToggleBit(strData, 22)
strDisplay = strDisplay + "Toggle bit '22' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 30)
strDisplay = strDisplay + "Toggle bit '30' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 38)
strDisplay = strDisplay + "Toggle bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
Call cToggleBit(strData, 22)
strDisplay = strDisplay + "Toggle bit '22' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 30)
strDisplay = strDisplay + "Toggle bit '30' is '" & strData & "'" & vbCrLf
Call cToggleBit(strData, 38)
strDisplay = strDisplay + "Toggle bit '38' is '" & strData & "'" & vbCrLf & vbCrLf
lbl_Result = strDisplay
'time the function
TimerHandle = cTimerOpen()
TimerStartOk = cTimerStart(TimerHandle)
For i = 1 To Iteration
Call cToggleBit(strData, 0)
Next i
mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
TimerCloseOk = cTimerClose(TimerHandle)
End Sub